const fnDown = (el: { offsetLeft: any; offsetTop: any; style: { left: string; top: string; }; }, ev: { clientX: any; clientY: any; }) => {
  console.log(ev)
  let currentX = el.offsetLeft
  let currentY = el.offsetTop

  let downX = ev.clientX
  let downY = ev.clientY

  const fnMove = (ev: { clientX: number; clientY: number; }) => {
    let left = ev.clientX - downX + currentX
    let top = ev.clientY - downY + currentY
    el.style.left = left + 'px'
    el.style.top = top + 'px'
  }

  let fnUp: (ev: any) => void
  fnUp = ev => {
    document.removeEventListener('mousemove', fnMove, false)
    document.removeEventListener('mouseup', fnUp, false)
  }
  document.addEventListener('mousemove', fnMove, false)
  document.addEventListener('mouseup', fnUp, false)
  return false
}

export default (el: { offsetLeft?: any; offsetTop?: any; style?: { left: string; top: string; }; addEventListener?: any; }) => {
  console.log('该元素被选中啦')
  console.log(el)
  // @ts-ignore
  el.addEventListener('mousedown', fnDown.bind(null, el), false)
}
